package com.synjones.handsetS8;

import android.os.Environment;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created by zhaodianbo on 2016-7-29.
 */
public class MyUtils {
    public static void sleep(long t){
        try{
            Thread.sleep(t);
        }catch (Exception e){}
    }

    public static String getExternalPath(){
        try {
            String ExternalPath= Environment.getExternalStorageDirectory().getCanonicalPath()+"/";
            return ExternalPath;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static boolean fileIsExists(String filename){
        try{
            File f=new File(filename);
            if(!f.exists()){
                return false;
            }

        }catch (Exception e) {
            // TODO: handle exception
            return false;
        }
        return true;
    }

    public static boolean writeStr2SdcardFile(String fileName,String write_str){
        boolean ret=false;
        try{
            FileOutputStream fout = new FileOutputStream(fileName);
            byte [] bytes = write_str.getBytes();
            fout.write(bytes);
            fout.close();
            ret=true;
        }
        catch(Exception e){
            e.printStackTrace();
        }
        return ret;

    }
}
